import request from '@/utils/request'
import qs from "qs"

export default {
    //分页条件查询
    pageInfo(currentPage, pageSize, formInline) {
        const data = qs.stringify({ "pageNum": currentPage, "pageSize": pageSize, "name": formInline.name, "roleId": formInline.roleId,"sort": formInline.sort })//"name": formInline.name
        return request({
            url: '/api-sys/user/users',
            method: 'post',
            data
        })
    },
    //删除
    deleteById(id) {
        return request({
            url: `/api-sys/user/user/${id}`,
            method: "delete"
        })
    },
    //编辑
    updateById(user) {
        const data = qs.stringify({
            "id": user.id, "username": user.username,
            "password": user.password, "nickName": user.nickName,
            "email": user.email, "createDate": user.createDate,
            "updateDate": user.updateDate, "roleId": user.roleId
        })
        return request({
            url: "/api-sys/user/user",
            method: "put",
            data
        })
    },
    //添加
    add(user) {
        const data = qs.stringify({
            "id": user.id, "username": user.username,
            "password": user.password, "nickName": user.nickName,
            "email": user.email, "createDate": user.createDate,
            "updateDate": user.updateDate, "roleId": user.roleId
        })
        return request({
            url: "/api-sys/user/user",
            method: "post",
            data
        })
    }
}